package com.hy.mydesktop.client.component.factory;

import com.extjs.gxt.ui.client.data.BaseTreeModel;
import com.extjs.gxt.ui.client.data.TreeModel;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.hy.mydesktop.client.component.meta.TreePanelModelEnum;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaNodeModel;



/**
 * 
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-9-9；时间：上午10:16:43</li>
 * <li>类型名称：TreePanelFactory</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
public class TreePanelFactory {
	
	/*private static	TreeServiceAsync treeService=GWT.create(TreeService.class); 

	public static TreePanel<TreeModel> createTreePanle(GxtComponentMetaNodeModel gxtComponentMetaNodeModel){
		return configureTreePanel(gxtComponentMetaNodeModel);
	}
	
	*//**
	 * 
	 * <ul>
	 * <li>方法含义：配置treepanel属性</li>
	 * <li>方法作者：汤莉</li>
	 * <li>编写日期：2010-9-9；时间：下午上午10:19:11</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @param gxtComponentMetaNodeModel
	 * @return
	 *//*
	private static TreePanel<TreeModel> configureTreePanel(GxtComponentMetaNodeModel gxtComponentMetaNodeModel){
		
		final TreeStore<TreeModel> store=new TreeStore<TreeModel>();
		treeService.getTreeModel(new AsyncCallback<TreeModel>() {
			@Override
			public void onSuccess(TreeModel result) {
				store.add(result, true);
			}
			@Override
			public void onFailure(Throwable caught) {
			}
		});
		
		TreePanel<TreeModel> tree=defaultCreateTreePanel(store);
		//设置显示信息的字段
		if(gxtComponentMetaNodeModel.get(TreePanelModelEnum.DISPLAYPROPERTY.name().toLowerCase())!=null){
			String propety=(String)gxtComponentMetaNodeModel.get(TreePanelModelEnum.DISPLAYPROPERTY.name().toLowerCase());
			tree.setDisplayProperty(propety);
		}
		//设置是否展开树
		if(gxtComponentMetaNodeModel.get(TreePanelModelEnum.EXPAND.name().toLowerCase())!=null){
			boolean expand=(Boolean)gxtComponentMetaNodeModel.get(TreePanelModelEnum.EXPAND.name().toLowerCase());
			TreeModel model=new BaseTreeModel();
			tree.setExpanded(model, expand);
		}
		//设置叶子节点的图标
		if(gxtComponentMetaNodeModel.get(TreePanelModelEnum.ICON.name().toLowerCase())!=null){
			AbstractImagePrototype icon=(AbstractImagePrototype)gxtComponentMetaNodeModel.get(TreePanelModelEnum.ICON.name().toLowerCase());
			tree.getStyle().setLeafIcon(icon);
		}
		
		
		return tree;
	}
	
	*//**
	 * 
	 * <ul>
	 * <li>方法含义：创建默认的treepanel</li>
	 * <li>方法作者：汤莉</li>
	 * <li>编写日期：2010-9-9；时间：下午上午10:22:17</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @param store
	 * @return
	 *//*
	private static TreePanel<TreeModel> defaultCreateTreePanel(TreeStore<TreeModel> store)
	{
		TreePanel<TreeModel> tree=new TreePanel<TreeModel>(store);
		return tree;
	}*/
}
